﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PetaPoco
{
    [Serializable]
    public abstract class BaseEntity
    {
        //public abstract string TableNameInDb
        //{
        //    get;
        //    set;
        //}
    }
    public class ResultSet
    {
        public ResultSet()
        {
            this.IsSuccess = true;
        }

        /// <summary>
        /// 失败返回信息
        /// </summary>
        /// <param name="message"></param>
        public ResultSet(string message)
        {
            this.Message = message;
            this.IsSuccess = false;
        }

        /// <summary>
        /// 返回成功或失败信息
        /// </summary>
        /// <param name="isSuccess">是否执行成功</param>
        /// <param name="message">返回信息</param>
        /// <param name="messageArgs">消息参数，兼容多语言</param>
        /// <author>柯广强 2015.11.9</author>
        public ResultSet(bool isSuccess, string message, params string[] messageArgs)
        {
            this.Message = message;
            this.IsSuccess = isSuccess;
            this.MessageArgs = messageArgs;
        }

        /// <summary>
        /// 失败返回信息
        /// </summary>
        /// <param name="isSuccess">是否执行成功</param>
        /// <param name="message">提示信息</param>
        /// <param name="messageArgs">信息参数</param>
        /// <author>柯广强 2015.11.10</author>
        public ResultSet(bool isSuccess, string message, params object[] messageArgs)
        {
            this.Message = message;
            this.Data = message;
            this.IsSuccess = isSuccess;
            this.MessageArgs = messageArgs;
        }

        /// <summary>
        /// 失败返回信息
        /// </summary>
        /// <param name="message"></param>
        public ResultSet(string message, params object[] messageArgs)
        {
            this.Message = message;
            this.IsSuccess = false;
            this.MessageArgs = messageArgs;
        }

        /// <summary>
        /// 成功返回数据
        /// </summary>
        /// <param name="data"></param>
        public ResultSet(object data)
        {
            this.Data = data;
            this.IsSuccess = true;
        }

        /// <summary>
        /// 是否成功
        /// </summary>
        public bool IsSuccess { get; set; }

        /// <summary>
        /// 消息
        /// </summary>
        public string Message { get; set; }

        /// <summary>
        /// 消息参数，兼容提示信息多语言
        /// </summary>
        /// <author>柯广强 2015/10/30</author>
        public object[] MessageArgs { get; set; }

        /// <summary>
        /// 数据
        /// </summary>
        public object Data { get; set; }

        /// <summary>
        /// 消息队列数据
        /// </summary>
        public object Equeue_ProductRackStockData { get; set; }

        /// <summary>
        /// 页面选中主键
        /// </summary>
        public object CheckedKey { get; set; }

        /// <summary>
        /// 可定制编号
        /// </summary>
        public int Code { get; set; }

        /// <summary>
        /// 调拨请求消息队列数据
        /// </summary>
        /// <author>张水场 2015/11/3</author>
        public object Equeue_ProductShiftRequestData { get; set; }

        /// <summary>
        /// 盘点申请消息队列数据
        /// </summary>
        public object Equeue_ProductCheckRequestData { get; set; }
        /// <summary>
        /// 流转单消息队列数据
        /// </summary>
        /// <author>张水场 2015/11/17</author>
        public object Equeue_PurchasePackageData { get; set; }
    }

    public class FastResultSet
    {
        private static ResultSet _success;

        static FastResultSet()
        {
            _success = new ResultSet() { IsSuccess = true };
        }

        public static ResultSet Success()
        {
            return _success;
        }

        public static ResultSet Fail(string message, params object[] args)
        {
            return new ResultSet(message, args);
        }

        public static ResultSet Fial(string message, int code, params object[] args)
        {
            var rs = new ResultSet(message, args);
            rs.Code = code;
            return rs;
        }
    }
}
